<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    request.setAttribute("basePath", basePath);
%>
<%@ include file="/resources/js/easyui/taglibs.jsp" %>
<%@ include file="/resources/js/wechat/_wechatui.jsp" %>
<%@ include file="/resources/js/easyui/_viewJS.jsp" %>
<!DOCTYPE>
<html>
<head>
    <title>账目详情</title>
</head>
<body>
<div class="loading"></div>
<!-- header -->
<header>
    <a href="javascript:history.go(-1);" class="top_fh">${income.placeName} ${income.deviceName}</a>
</header>
<!-- header end -->

<div class="page zmxqmiao_page">
    <div class="zmxq_miaoinner">
        <c:if test="${income.incomeItems == null || fn:length(income.incomeItems) <= 0}">
            <ul>
                <li>
                    <fmt:parseDate value="${income.queryDate}" pattern="yyyy-MM-dd" var="queryDate"/>
                    <time></time>
                    <div>该设备在<fmt:formatDate value="${queryDate}" pattern="yyyy年MM月dd日"/>尚未产生流水帐</div>
                </li>
            </ul>
        </c:if>
        <c:if test="${income.incomeItems != null && fn:length(income.incomeItems) > 0}">
            <ul id="GC_device_income_item">
                <c:forEach items="${income.incomeItems}" var="item" varStatus="status">
                    <li>
                        <time>${item.incomeTime}</time>
                        <div>${item.incomeText}</div>
                    </li>
                </c:forEach>
            </ul>
            <div class="zmxq_more"><a id="GC_device_thatday_details_more" moreindex="${income.moreIndex}"
                                      href="javascript:void(0);">查看更多</a></div>
        </c:if>
    </div>
</div>
</body>
</html>
<script>
    var moreindex = ${income.moreIndex + 1};
    var islastDate = false;
    /*当天流水账*/
    $("#GC_device_thatday_details_more").click(function () {
        if(islastDate == false){
            $.ajax({
                url: '${basePath}wechat/income/accounts/${placeid}/detailsmore',
                type: 'GET',
                data: {
                    "deviceSerial": ${income.deviceid},
                    "queryDate": "${income.queryDate}",
                    "moreindex": moreindex
                }, error: function (response) {
                    ViewHelper.func.ajaxWechatErrorMessage(response);
                }, success: function (ret) {
                    if (ret.result) {
                        moreindex = ret.income.moreIndex + 1;
                        $.each(ret.income.incomeItems, function (index, item) {
                            $("#GC_device_income_item").append("<li id="+item.incomeItemid+"><time>" + item.incomeTime + "</time><div>" + item.incomeText + "</div></li>");
                        });
                    } else {
                        alert(ret.info);
                        islastDate = true;
                    }
                }
            });
        }else{
            alert("已经没有更多的账目信息了！");
        }


    });

</script>